#include<stdio.h>
const int Inf=1e8;
char map[5][5];
int ans=Inf;
void flip(int x,int y){
	map[x][y]=(map[x][y]=='b')?'w':'b';
	if(x-1>=0)
		map[x-1][y]=(map[x-1][y]=='b')?'w':'b';
	if(x+1<4)
		map[x+1][y]=(map[x+1][y]=='b')?'w':'b';
	if(y+1<4)
		map[x][y+1]=(map[x][y+1]=='b')?'w':'b';
	if(y-1>=0)
		map[x][y-1]=(map[x][y-1]=='b')?'w':'b';
	return;
}
int check(){
	int i,j;
	for(i=0;i<4;i++)
		for(j=0;j<4;j++)
			if(map[i][j]!=map[0][0])
				return 0;
	return 1;
}
void dfs(int pos,int step)
{
	int x=pos/4;
	int y=pos%4;
	if(pos==16)	{
		if(check())
			ans=ans<step?ans:step;
		return;
	}
	flip(x,y);
	dfs(pos+1,step+1);
	flip(x,y);
	dfs(pos+1,step);
	return;
}
int main()
{
	int i,j;
	for(i=0;i<4;i++)
		scanf("%s",map[i]);
	dfs(0,0);
	if(ans==Inf)	printf("Impossible\n");
	else	printf("%d\n",ans);
}
